/* 
 * File:   serverMain.cpp
 * Author: robbiediaz
 *
 * Created on January 27, 2009, 12:05 PM
 */

#include <iostream>
#include <string>
#include <vector>
#include "model/Conversation.h"
#include "model/Peer.h"
#include "network/socket.h"
#include "network/SocketFactory.h"
#include "xml/xmlprocessor.h"

using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {
    XmlProcessor processor;
    socketFactory fac;
    std::vector<Conversation> conversations;

    genericSocket* sock = fac.getSocket();

    bool run = true;

    Conversation convo;
    conversations.push_back(convo);

    Peer* p;

    p = sock->acceptConnection();
    convo.addPeer(*p);

    while (run) {
        cout << "Peer connected from: " << p->getIpAddr() << " " << p->getPort() << endl;
        sock->sendString("asdf\n");
        std::string str = sock->readString(p);
        cout << "recv: '" << str << "'" << endl;
        if(str.find("exit") != std::string::npos){
            run = false;
            break;
        }

        //processor.parseStream(str);
    }
    return (EXIT_SUCCESS);
}

